package test.algos.sorting;

import static test.algos.sorting.input.InputData.INPUT_DATA;

public class InsertionSort implements Sort {

	@Override
	public void sort() {

		System.out.println("Before Sorter:" + INPUT_DATA);

		for (int i = 0; i < INPUT_DATA.size(); i++) {

			Integer curData = INPUT_DATA.get(i);

			for (int prevIndex = i - 1,curIndex=i; prevIndex >= 0; prevIndex--,curIndex--) {
				Integer prevData=INPUT_DATA.get(prevIndex);
				
				if(curData < prevData){
					INPUT_DATA.set(curIndex, prevData);
					INPUT_DATA.set(prevIndex, curData);
					
				}
			}

		}

		System.out.println("After Sorter:" + INPUT_DATA);

	}

}
